//
//  LLControllerTool.m
//  sina
//
//  Created by 李灵斌 on 15-1-14.
//  Copyright (c) 2015年 apple. All rights reserved.
//

#import "LLControllerTool.h"
#import "LLWelComeViewController.h"
#import "LLNewFeatureController.h"
#import "LLAccountTool.h"
#import "LLTabBarController.h"
@implementation LLControllerTool

+ (void)chooseRootViewController{
    
    LLAccount *account = [LLAccountTool readInShaHe];
    UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
    if (account) { // 拿到授权
        
        // 判断是否是新版本
        NSString *infoDict =[NSBundle mainBundle]. infoDictionary[@"CFBundleShortVersionString"];
        NSString *shaHeVerson = [[NSUserDefaults standardUserDefaults] objectForKey:@"CFBundleShortVersionString"];
        
        if ([infoDict compare:shaHeVerson] == NSOrderedDescending) { // 新特性页面
            
            keyWindow.rootViewController = [[LLNewFeatureController alloc] init];
            
            // 保存版本号到沙盒
            [[NSUserDefaults standardUserDefaults] setObject:infoDict forKey:@"CFBundleShortVersionString"];
            [[NSUserDefaults standardUserDefaults] synchronize];
        } else { // 欢迎页面
            
            keyWindow.rootViewController = [[LLWelComeViewController alloc] init];
        }
        
    } else { // 没有授权到default页面
        
        keyWindow.rootViewController = [[LLTabBarController alloc] init];
    }

}

@end
